/* 
 * AUTHOR: Kevin Lam
 */

package com.apps.utils;

public class EmailUtils {
	
	private static final String EMAIL_VALIDATION_REGEX = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}";
	private static final String VERIFICATION_MESSAGE_TEMPLATE = "Welcome aboard!\n\n\tIn order to validate your account, please click the following link (if it doesn't work copy and paste the URL to your browser): http://ubc-cc.appspot.com/activate?user=<USER>&auth=<AUTH>\n\n UBC Course Companion";
	
	private static final String NS_VERIFY_TEMPLATE = "Hello,\n\n\tYou have received this email because you have submitted a course notification request for the course <COURSE>. If you would like to confirm your notification request please click the following link (if it doesn't work copy and paste the URL to your browser): http://ubc-cc.appspot.com/nsverify?key=<KEY>\n\n\t If you believe you have received this message by mistake OR do not wish to confirm your notification request, please ignore this email and the key will expire in 1 hour. \n\n UBC Course Companion";
	
	public static boolean isValidEmail(String in){
		return in.toUpperCase().matches(EMAIL_VALIDATION_REGEX);
	}
	
	public static String getVerificationMessageBody(String user, String auth){
		return VERIFICATION_MESSAGE_TEMPLATE.replaceAll("<USER>", user).replaceAll("<AUTH>", auth);
	}
	
	public static String getNSVerify(String key, String course){
		return NS_VERIFY_TEMPLATE.replaceAll("<COURSE>", course).replaceAll("<KEY>", key);
	}

}
